const { createWebAPIRequest } = require('../../util/util')
module.exports = [
  {
    /**
    * @api {get} /music/recommend/songs [获取每日推荐歌曲]
    * @apiGroup Music
    * @apiPermission none
    * @apiParam {Number} [offset=0] 页
    * @apiParam {Number} [limit=20]  每页数量
    */
    url: '/music/recommend/songs',
    request: (req, res) => {
      const cookie = req.get('Cookie') ? req.get('Cookie') : ''
      const {offset, limit} = req.query
      const data = {
        offset: Number(offset) || 0,
        total: true,
        limit: Number(limit) || 20,
        csrf_token: ''
      }

      createWebAPIRequest(
        'music.163.com',
        '/weapi/v1/discovery/recommend/songs',
        'POST',
        data,
        cookie,
        musicReq => res.send(musicReq),
        err => res.status(500).send({err})
      )
    }
  }, {
    /**
    * @api {get} /music/recommend/resource [获取每日推荐歌单]
    * @apiGroup Music
    * @apiPermission none
    */
    url: '/music/recommend/resource',
    request: (req, res) => {
      const cookie = req.get('Cookie') ? req.get('Cookie') : ''
      const data = {
        csrf_token: ''
      }

      createWebAPIRequest(
        'music.163.com',
        '/weapi/v1/discovery/recommend/resource',
        'POST',
        data,
        cookie,
        musicReq => res.send(musicReq),
        err => res.status(500).send({err})
      )
    }
  }, {
    /**
    * @api {get} /music/recommend/dislike [取消推荐]
    * @apiGroup Music
    * @apiPermission none
    */
    url: '/music/recommend/dislike',
    request: (req, res) => {
      const cookie = req.get('Cookie') ? req.get('Cookie') : ''
      const data = {
        csrf_token: ''
      }

      createWebAPIRequest(
        'music.163.com',
        '/weapi/v1/radio/get',
        'POST',
        data,
        cookie,
        musicReq => res.send(musicReq),
        err => res.status(500).send({err})
      )
    }
  }
]
